習慣上的寫法


Posted by mijouhsieh on 2023-05-01

outline:
Promise 物件實例中,

1 Promise 物件實例中,例子裡沒有設計 reject - catch 的段落,因此參數寫 _reject

在習慣上,加底線表示後面沒有用到這個參數。

 new Promise((resolve, _reject) => {
    for (const [user_index, user] of users.entries()) {
      // 創建使用者資料(user): model.create
      UserModel.create({
        ...user
      }).then((user) => {
        // 對每個user建立相對應餐廳資料
        return RestaurantModel.create(restaurants)
      }).then(() => {
        resolve()
      }).catch(error => {
        console.log(error)
      })
    }
  }).then(() => {
    // 等待所有使用者的餐廳資料創建完成
    console.log('所有使用者與餐廳資料創建完成')
    process.exit()
  })

#習慣上的寫法







Related Posts

[python] 關於 numpy 以及1~5維度的資料

[python] 關於 numpy 以及1~5維度的資料

[ CSS 03 ]  盒模型(box model)與定位(position)

[ CSS 03 ] 盒模型(box model)與定位(position)

[Day 01] - Vault 的簡單介紹及安裝

[Day 01] - Vault 的簡單介紹及安裝


Comments